package com.jh.readme.iu.activity.ndetail;

import com.jh.tools.api.Api;
import com.jh.tools.api.HostType;
import com.jh.tools.api.manager.RetrofitManager;
import com.jh.tools.bean.NeteastNewsDetail;
import com.jh.tools.bean.NeteastNewsSummary;

import java.util.List;
import java.util.Map;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.functions.Func2;

/**
 * Created by niejiahuan on 2016/5/31.
 */
public class NewsDetailModel implements NewsDetailContract.Model {
    @Override
    public Observable<Map<String, NeteastNewsDetail>> getNewsDetailDate(final String newsId) {
        Observable<Map<String, NeteastNewsDetail>> neteastNewsDetail=RetrofitManager.builder(Api.NETEAST_HOST).getNewsDetailObservable(newsId);
        neteastNewsDetail.doOnSubscribe(new Action0() {
                    @Override
                    public void call() {

                    }
                }).subscribeOn(AndroidSchedulers.mainThread())
                .map(new Func1<Map<String, NeteastNewsDetail>, NeteastNewsDetail>() {
                    @Override
                    public NeteastNewsDetail call(Map<String, NeteastNewsDetail> map) {
                        return map.get(newsId);
                    }
                });

        return neteastNewsDetail;
    }

    @Override
    public Observable getDate(Map<String, String> map) {
        return null;
    }
}
